#include <stdlib.h>
#include <string.h>

#include "els_vm.h"
#include "els.h"

void els_vm_free (void *block){
    *((int *)block) = -1;  
    free(block);
}


void *els_vm_malloc (unsigned long size){
    void *block = malloc((size_t)size);
    if (block == NULL) els_error("没有足够内存");
    return block;
}


void *els_vm_realloc (void *oldblock, unsigned long size){
    void *block = realloc(oldblock, (size_t)size);
    if (block == NULL) els_error("没有足够的内存");
    return block;
}


char *els_vm_strdup (char *str){
    char *newstr = els_vm_malloc(strlen(str)+1);
    strcpy(newstr, str);
    return newstr;
}
